<!--Copyright (C) Kherty.  All rights reserved.-->
<ResourceDictionary
  x:Class="OpenLS.Spreadsheet.UI.BackgroundFormatterResources"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:ss="http://schemas.Kherty.com/office/2007/spreadsheet" 
    xmlns:ssui="clr-namespace:OpenLS.Spreadsheet.UI"
  xmlns:drawing2="clr-namespace:OpenLS.Drawing.UI;assembly=OpenLS.Drawing.UI"
  xmlns:Internals="clr-namespace:OpenLS.Spreadsheet.UI.Internals"
  xmlns:Resources="clr-namespace:OpenLS.Spreadsheet.UI.Internals.Resources">
    <DataTemplate x:Key="backgroundTemplate">
  <Grid>
    <Grid.ColumnDefinitions>
      <ColumnDefinition Width="*"/>
      <ColumnDefinition Width="*"/>
    </Grid.ColumnDefinitions>
    <Grid.RowDefinitions>
      <RowDefinition/>
      <RowDefinition/>
      <RowDefinition/>
    </Grid.RowDefinitions>
        <StackPanel Orientation="Horizontal">    
            <Label Content="{x:Static Resources:UIStringTable.BackgroundColor}"/>
            <Label Content=" :"/>
            </StackPanel>
        <StackPanel Grid.Column="1" Orientation="Horizontal">
            <Label Content="{x:Static Resources:UIStringTable.PatternColor}" Grid.Column="1"/>
            <Label Content=" :"/>
        </StackPanel>
    <StackPanel Grid.Row="1">
      <Button Content="{x:Static Resources:UIStringTable.NoColor}" Click="OnSetNoBackground" Margin="4"/>
      <ListBox ItemsSource="{Binding AllColors}" BorderBrush="Transparent" Background="Transparent" SelectionChanged = "OnBackgroundChanged">
        <ListBox.ItemTemplate>
          <HierarchicalDataTemplate DataType="{x:Type ss:SpreadsheetColor}">
            <Border
                    Width="13" Height="13" Margin="0" BorderThickness="1" BorderBrush="LightGray" SnapsToDevicePixels="True">
              <Border.Background>
                <MultiBinding Converter="{x:Static Internals:SpreadsheetConverters.ColorToBrushConverter}">
                  <Binding/>
                  <Binding RelativeSource="{RelativeSource Self}" Path="(drawing2:DrawingElement.ColorScheme)"/>
                </MultiBinding>
              </Border.Background>
            </Border>
            </HierarchicalDataTemplate>
        </ListBox.ItemTemplate>
        <ListBox.ItemContainerStyle>
          <Style TargetType ="{x:Type ListBoxItem}">
            <Setter Property ="Margin" Value="1 1 0 0"/>
            <Setter Property ="Template">
              <Setter.Value>
                <ControlTemplate TargetType="{x:Type ListBoxItem}">
                  <Border BorderThickness="1" BorderBrush="Transparent" x:Name="Bd" Padding="1" CornerRadius="1">
                    <ContentPresenter/>
                  </Border>
                  <ControlTemplate.Triggers>
                    <Trigger Property="IsMouseOver" Value="True">
                      <Setter Property="BorderBrush" Value="LightGray" TargetName="Bd"/>
                    </Trigger>
                    <Trigger Property="IsSelected" Value="True">
                      <Setter Property="BorderBrush" Value="Gray" TargetName="Bd"/>
                    </Trigger>
                  </ControlTemplate.Triggers>
                </ControlTemplate>
              </Setter.Value>
            </Setter>
          </Style>
        </ListBox.ItemContainerStyle>
        <ListBox.ItemsPanel>
          <ItemsPanelTemplate>
            <WrapPanel MaxWidth="190"/>
          </ItemsPanelTemplate>
        </ListBox.ItemsPanel>
      </ListBox>
    </StackPanel>
    <GroupBox Header="{x:Static Resources:UIStringTable.Sample}" Grid.Row="2" Grid.ColumnSpan="2">
      <Rectangle Height="30" HorizontalAlignment="Stretch">
        <Rectangle.Fill>
          <MultiBinding Converter="{x:Static Internals:SpreadsheetConverters.FillToBackgroundBrushConverter}">
            <Binding Path="Background" />
            <Binding RelativeSource="{RelativeSource Self}" Path="(drawing2:DrawingElement.ColorScheme)"/>
          </MultiBinding>
        </Rectangle.Fill>
      </Rectangle>
    </GroupBox>
  </Grid>
</DataTemplate>
</ResourceDictionary>
